home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CDTV / cdtvtools-11 / keeper / keeper.i < prev    next >
Encoding:
Text File  |  1991-06-24  |  3.8 KB  |  184 lines

  1.  
  2. *
  3. * stdasm.i : ray's standard assembler thingies
  4. *
  5.         INCLUDE     "exec/exec_equ.i"
  6.         INCLUDE     "exec/types.i"
  7.         INCLUDE     "exec/libraries.i"
  8.  
  9. *
  10. * some constants
  11. *
  12. ABS_EXECBASE    EQU        4
  13. CHIPBASE    EQU        $00DFF000
  14. CIAABASE    EQU        $00BFE001
  15. CIABBASE    EQU        $00BFD000
  16.  
  17. *
  18. * standard library base pointers
  19. *
  20.         XREF        _DOSBase
  21.         XREF        _GfxBase
  22.         XREF        _IntuitionBase
  23.  
  24. *
  25. * macros
  26. *
  27. * use the following macro when A6 is correct
  28. *
  29. JSRLIB        MACRO
  30.         JSR        _LVO\1(A6)
  31.         ENDM
  32. *
  33. * use the following macros when A6 is incorrect
  34. *
  35. JSRSYS        MACRO
  36.         MOVE.L        ABS_EXECBASE,A6
  37.         JSRLIB        \1
  38.         ENDM
  39.  
  40. JSRDOS        MACRO
  41.         MOVE.L        _DOSBase,A6
  42.         JSRLIB        \1
  43.         ENDM
  44.  
  45. JSRINT        MACRO
  46.         MOVE.L        _IntuitionBase,A6
  47.         JSRLIB        \1
  48.         ENDM
  49.  
  50. JSRGFX        MACRO
  51.         MOVE.L        _GfxBase,A6
  52.         JSRLIB        \1
  53.         ENDM
  54.  
  55. *
  56. * miscellaneous
  57. *
  58. INC        MACRO
  59.         addq.\0        #1,\1
  60.         ENDM
  61.  
  62. DEC        MACRO
  63.         subq.\0        #1,\1
  64.         ENDM
  65.  
  66. BLO        MACRO
  67.         bcs.\0        \1
  68.         ENDM
  69.  
  70. BHS        MACRO
  71.         bcc.\0        \1
  72.         ENDM
  73.  
  74. PUSH        MACRO
  75.         move.\0        \1,-(sp)
  76.         ENDM
  77.  
  78. PULL        MACRO
  79.         move.\0        (sp)+,\1
  80.         ENDM
  81.  
  82. PUSHM        MACRO
  83.         movem.\0    \1,-(sp)
  84.         ENDM
  85.  
  86. PULLM        MACRO
  87.         movem.\0    (sp)+,\1
  88.         ENDM
  89.  
  90. * USAGE: FUNCTION <function name>,<size of stack frame>[,<reg list for save>]
  91. * FUNCTION macro; declares a C-language-callable function; may also be used
  92. * for any function which expects a C-language-like interface (stack frame,
  93. * etc.); function is externally defined (XDEF); A5 is saved and an optional 
  94. * local stack frame is created both using the LINK instruction (if no local
  95. * stack frame is required pass 0 for <size of stack frame>); an optional
  96. * register list may also be provided to be saved via MOVEM.L
  97. FUNCTION    MACRO
  98.         XDEF        \1
  99. \1        link        a5,#-\2
  100.         IFEQ NARG-3
  101. \1_REGS        REG        \3
  102.         movem.l        \3,-(sp)
  103.         ENDC
  104.         ENDM
  105.  
  106. * USAGE: RETURN <function name>
  107. * RETURN macro; returns from a C-language-callable function which was defined
  108. * with the FUNCTION macro; any registers that were saved by FUNCTION are
  109. * restored and UNLK is called to restore A5 and to free the local stack
  110. * frame; lastly, RTS is exectued
  111. RETURN        MACRO
  112.         IFD \1_REGS
  113.         movem.l        (sp)+,\1_REGS
  114.         ENDC
  115.         unlk        a5
  116.         rts
  117.         ENDM
  118.  
  119. * USAGE: ARGUMENT [offset]
  120. * ARGUMENT macro; initializes argument pointer for ARG macro;
  121. * optional argument replaces stack frame default offset which is 8 based on
  122. * existence of return address and usage of the LINK instruction;
  123. ARGUMENTS    MACRO
  124.         IFEQ NARG-1
  125. _ARGPT_        SET        \1
  126.         MEXIT
  127.         ENDC
  128. _ARGPT_        SET        8
  129.         ENDM
  130.  
  131. * USAGE: ARG <type>, <name>
  132. * ARG macro; assigns current argument pointer to argument name and
  133. * advances argument pointer to next argument position; argument pointer
  134. * is advanced by the size of the argument data type; for unusual data types
  135. * a label or numeric constant may be used in place of argument type;
  136. * argument type should otherwise be one of those defined below
  137. ARG        MACRO
  138. \2        SET        _ARGPT_
  139. _ARGPT_        SET        _ARGPT_+\1
  140.         ENDM
  141.  
  142. * USAGE: LOCAL_STACK [start]
  143. * LOCAL_STACK macro; initializes the stack frame pointer for the AUTO macro;
  144. * optional start value may be used to initilize the stack frame pointer to
  145. * a value other than the default of 0
  146. LOCAL_STACK    MACRO
  147.         IFEQ NARG-1
  148. _AUTOPT_    SET        \1
  149. SFSIZE        SET        +\1
  150.         MEXIT
  151.         ENDC
  152. _AUTOPT_    SET        0
  153. SFSIZE        SET        0
  154.         ENDM
  155.  
  156. * USAGE: AUTO <type>, <name>
  157. * AUTO macro; assigns current stack frame pointer to argument name and
  158. * advances stack frame pointer to next stack frame position; stack frame 
  159. * pointer is advanced by the size of the argument data type; for unusual 
  160. * data types a label or numeric constant may be used in place of argument 
  161. * type; argument type should otherwise be one of those defined below
  162. AUTO        MACRO
  163. _AUTOPT_    SET        _AUTOPT_-\1
  164. \2        SET        _AUTOPT_
  165. SFSIZE        SET        SFSIZE+\1
  166.         ENDM
  167.  
  168. * argument types
  169. _BOOL        EQU        2
  170. _BYTE        EQU        1
  171. _UBYTE        EQU        1
  172. _WORD        EQU        2
  173. _UWORD        EQU        2
  174. _SHORT        EQU        2
  175. _USHORT        EQU        2
  176. _LONG        EQU        4
  177. _ULONG        EQU        4
  178. _FLOAT        EQU        4
  179. _APTR        EQU        4
  180. _BPTR        EQU        4
  181. _CPTR        EQU        4
  182. _RPTR        EQU        2
  183. _LABEL        EQU        0
  184.